<%- include header %>
<!-- 主题内容start -->
<div style="position: relative">
    <div style="width: 230px;height:300px;float: left;border: 1px dotted #9f9d93;position: absolute;top:50px;left: 700px">
        <img id="img_poster"  src="" style="width: 230px;height: 300px">
        <div class="circular" style="position: absolute;top:120px;left:50px;z-index:10;text-align:center;line-height: 20px;width:130px;height: 40px;background-color: #d77a03;">
            <h4 style="color: white;line-height: 20px">详情</b></h4>
        </div>
        <div class="file-box" style="margin-top: 20px">
            <form action="" id="uploadPoster" method="post" enctype="multipart/form-data">
                <input type='text' name='textfield' id='textfield' class='txt' style="margin-bottom: 0px"/>
                <input type='button' class='btn' value='浏览...' />
                <input type="file" name="file" class="file" id="fileToUpload" size="28" onchange="document.getElementById('textfield').value=this.value" />
                <input type="submit" name="submit" class="btn" value="上传" onclick="return ajaxFileUpload();"/>
            </form>

        </div>
    </div>
    <form class="form-horizontal" action="" method="post">
        <fieldset>
            <legend>咖啡厅添加</legend>
            <div class="control-group">
                <label class="control-label">名称</label>
                <div class="controls">
                    <input type="text" class="input-xlarge"  name="name">
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">地址</label>
                <div class="controls">
                    <select id="province" name="province" style="width: 100px" onchange="loadCity(this);">
                        <option value="">请选择</option>
                        <% datas.forEach(function(data,index){%>
                        <option value="<%- data._id %>"><%- data.name %></option>
                        <% }) %>
                    </select>
                    <select id="city" name="city" style="width: 100px" onchange="loadArea(this)">
                        <option value="">请选择</option>
                    </select>
                    <select id="area" name="area" style="width: 100px">
                        <option value="">请选择</option>
                    </select>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label" for="username">详细地址</label>
                <div class="controls">
                    <input type="text" class="input-xlarge"  name="addr">
                </div>
            </div>
            <!--<div class="control-group">-->
            <!--<label class="control-label" for="password">简介</label>-->
            <!--<div class="controls">-->

            <!--<script id="container" name="intro" type="text/plain"></script>-->
            <!--</div>-->
            <!--</div>-->
            <div style="height: 200px"></div>
            <div class="form-actions">
                <button type="submit" class="btn btn-primary">提交</button>
            </div>
        </fieldset>
    </form>
</div>


<!-- 主题内容end -->
<%- include footer %>
<script type="text/javascript">
    var ue = UE.getEditor('container',{
        initialFrameWidth:650,
        enableAutoSave:false,
        initialFrameHeight:171,
        saveInterval:60000
    });
</script>
<script>
    function loadCity(obj){
        $.ajax({
            type: "get",
            url: "/manager/loadCity?pid="+obj.value,
            success: function(result){
                $("#city").html(result);
            }
        });
    }
    function loadArea(obj){
        $.ajax({
            type: "get",
            url: "/manager/loadArea?cid="+obj.value,
            success: function(result){
                $("#area").html(result);
            }
        });
    }
    function ajaxFileUpload() {

        $.ajaxFileUpload({
            url : '/manager/uploadPoster',// servlet请求路径
            secureuri : false,
            fileElementId : 'fileToUpload',// 上传控件的id
            dataType:'text',
            success : function(data) {
                //alert(data);
                //alert(data.replace(/<.*?>/ig,''));

                if(data.indexOf('url')<0){
                    alert(data.replace(/<.*?>/ig,''));
                }
                eval("var jsobjjson="+data.replace(/<.*?>/ig,''));
                //alert(decodeURIComponent(jsobjjson.url))

                if(jsobjjson.state=='上传成功'){
                    //alert('111')
                    $("#img_poster").attr("src",decodeURIComponent(jsobjjson.url));
                }
            },
            error : function(data, status, e) {
                alert('上传出错');
            }
        })

        return false;

    }
</script>